#include <iterator_pattern.h>
#include <iostream>

NameIterator::NameIterator(NameRepository* l) : l(l), index(0) {}

bool NameIterator::hasNext()
{
    if(this->index < this->l->size())
    {
        return true;
    }
    return false;
}

NameIterator::~NameIterator()
{
    delete this->l;
}

void NameIterator::next()
{
    this->index += 1;
}

string NameIterator::currentItem()
{
    return this->l->at(this->index);
}

NameRepository::NameRepository(int size)
{
    this->list[0] = "Ro";
    this->list[1] = "Jo";
    this->list[2] = "Ju";
    this->list[3] = "Lo";
    this->count = size;
}

int NameRepository::size()
{
    return this->count;
}

string NameRepository::at(int index)
{
    string a = this->list[index];
    return a;
}

Iterator* NameRepository::getIterator()
{
    return new NameIterator(this);
}

void NameRepository::show()
{
    cout << "the length of list is : " << this->count << endl;
    for(int i = 0; i < 4; i++)
    {
        cout << this->list[i] << endl;
    }
}
